'use strict';

var path = require('path')
var webpack = require('webpack');

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
	entry: {
		list:[
			'./app/list.js'
		],
		detail:[
			'./app/detail.js'
		],
		mylist:[
			'./app/mylist.js'
		],
		vendors:[
			'react',
			'react-dom',
			'YmtApi'
		]
	},
	module: {
		loaders: [{
			test: /\.js$/,
			loaders: [
				'babel?presets[]=react,presets[]=es2015'
			],
			exclude: /node_modules/
		}, {
			test: /\.scss$/,
			//loader: 'style!css!sass'
			exclude: /node_modules/,
			loader:ExtractTextPlugin.extract('css!sass!autoprefixer')//不支持多参数
		}]
	},
	output: {
		path: path.join(__dirname, '.tmp'),
		publicPath:'http://static.tuan.ymatou.com/',
		filename: 'scripts/[name].js'
	},
	resolve:{
		alias:{
			'react':path.join(__dirname,'node_modules/react'),
			'react-dom':path.join(__dirname,'node_modules/react-dom'),
			'react-redux':path.join(__dirname,'node_modules/react-redux'),
			'YmtApi':path.join(__dirname,'node_modules/YmtApi/YmtApi.js')
		}
	},
	plugins: [
		new webpack.optimize.DedupePlugin(),
		//允许错误不打断程序
		new webpack.NoErrorsPlugin(),
		new webpack.optimize.OccurenceOrderPlugin(),
		new webpack.optimize.CommonsChunkPlugin('vendors','scripts/vendors.js'),
		new webpack.optimize.UglifyJsPlugin({
			compress:{
				drop_console:true
			}
			
		}),
		new ExtractTextPlugin('styles/[name].css',{
			allChunks:true
		}),
		new webpack.DefinePlugin({
			'process.env.NODE_ENV': JSON.stringify('production')
		})	
		// new HtmlWebpackPlugin({
		// 	title:'砍价团-详情页',
		// 	chunks:['detail','vendors'],
		// 	filename:'./app/views/detail.html',
		// 	template:'./app/views/detail_tpl.html',
		// 	inject: 'body',
		// 	hash:true
		// }),
		// new HtmlWebpackPlugin({
		// 	title:'砍价团-列表页', 
		// 	chunks:['list','vendors'],
		// 	filename:'./app/views/list.html',
		// 	template:'./app/views/detail_tpl.html',
		// 	inject: 'body',
		// 	hash:true
		// }),
		// new HtmlWebpackPlugin({
		// 	title:'砍价团-我的砍价团',
		// 	chunks:['mylist','vendors'],
		// 	filename:'./app/views/mylist.html',
		// 	template:'./app/views/detail_tpl.html',
		// 	inject: 'body',
		// 	hash:true
		// })
	]
}